import pandas as pd
import matplotlib.pyplot as plt
from core.utils.logging_handler import LoggingHandler

class ResultPresenter:
    def __init__(self, result):
        self.logger = LoggingHandler().get_logger()
        self.logger.info("初始化 ResultPresenter")
        self.result = result
    
    def display(self):
        self.logger.info("开始展示结果")
        if isinstance(self.result, pd.DataFrame) or isinstance(self.result, pd.Series):
            self.logger.info("展示 DataFrame 或 Series 类型的结果")
            print(self.result)
            self.result.plot(kind='bar')
            # plt.show()
        else:
            self.logger.info("展示简单结果")
            print(f"Query result: {self.result}")

